﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using dataAnnotations = DataAnnotationsExtensions;
using SchoolPointe.Menus.Enums;
using SchoolPointe.Menus.Models;


namespace SchoolPointe.Menus.ViewModels
{
    public class MenuItemCustomLinkViewModel : MenuItemViewModel
    {
        public MenuItemCustomLinkViewModel() : base()
        {
            MenuItemType = MenuItemType.CustomLink;
        }

        public MenuItemCustomLinkViewModel(BetterMenuItemPart part) : base(part)
        {            
            Url = part.Url;
            MenuItemType = MenuItemType.CustomLink;            
        }



        [dataAnnotations::Url(ErrorMessage = "Please enter a valid URL")]
        public string Url { get; set; }

        public override void UpdatePart(BetterMenuItemPart part)
        {
            part.Text = Text;
            part.Url = Url;
            part.MenuItemType = MenuItemType.CustomLink;
            part.SortOrder = SortOrder;
        }
    }
}